//
//  NetworkingTool.h
//  BaseFrameworkOC
//
//  Created by Vicent on 2021/9/6.
//

#import <Foundation/Foundation.h>

/*
 * 请求类型
 */
typedef enum : NSUInteger {
    BFHttpRequestTypeGet,
    BFHttpRequestTypePost,
} BFHttpRequestType;


static NSString *const kConsoleDebugPrefix = @"❤️";

/*
 * 成功回调
 */
typedef void(^BFHttpRequestSuccessBlock)(id responseObject);

/*
 * 成功回调
 */
typedef void(^BFHttpRequestFailedBlock)(NSError *error);

//超时时间
extern NSInteger const kBFNetworkingTimeoutInterval;


@interface NetworkingTool : NSObject

/**
 *  网络请求的实例方法
 *
 *  @param type         get / post (项目目前只支持这倆中)
 *  @param urlString    请求的地址
 *  @param parameters   请求的参数
 *  @param successBlock 请求成功回调
 *  @param failedBlock 请求失败回调
 */
+ (void)requestWithType:(BFHttpRequestType)type
             urlString:(NSString *)urlString
            parameters:(NSDictionary *)parameters
          successBlock:(BFHttpRequestSuccessBlock) successBlock
            failedBlock:(BFHttpRequestFailedBlock) failedBlock;

+ (void)postRequestWithApi:(NSString *)api
            parameters:(NSDictionary *)parameters
              successBlock:(void(^)(NSDictionary *rootDic)) successBlock
            failedBlock:(void(^)(id error)) failedBlock;

+ (void)getRequestWithApi:(NSString *)api
            parameters:(NSDictionary *)parameters
              successBlock:(void(^)(NSDictionary *rootDic)) successBlock
            failedBlock:(void(^)(id error)) failedBlock;

/**
 取消队列
 */
+(void)cancelDataTasks;

@end

